//
//  NYLearnRecordCell.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/22.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYLearnRecordCell.h"

#import "NYCourseModel.h"

@interface NYLearnRecordCell ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *videoLabel;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation NYLearnRecordCell

//MARK :Nimbus
- (BOOL)shouldUpdateCellWithObject:(NYCourseModel *)object {
        
    if (![object isKindOfClass:[NYCourseModel class]]) {
            return false;
    }
        [self updateContentWithModel:object];
    return true;
}
//+ (CGFloat)heightForObject:(id)object identifier:(NSString *)identifier atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView {
//
//    //    tableView.
//    return __WGHeight(45);
//}
- (void)setupView {
    [super setupView];
    
    //布局
    self.accessoryType = UITableViewCellAccessoryNone;
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.videoLabel];
    [self.contentView addSubview:self.lineView];

    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(15);
        make.top.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(-15);
        make.height.mas_equalTo(20);
    }];
    [self.videoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(15);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        make.right.equalTo(self.contentView).offset(-15);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(15);
        make.bottom.right.equalTo(self.contentView);
        make.height.mas_equalTo(1);
    }];

}
- (void)updateContentWithModel:(NYCourseModel *)model {
    
    _nameLabel.text = model.title;
    _videoLabel.text = model.currentPlayModel.video_title;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = UIFontMake(15);
        [_nameLabel setTextColor:UIColorMakeWithHex(@"#333333")];
    }
    return _nameLabel;
}
- (UILabel *)videoLabel {
    if (!_videoLabel) {
        _videoLabel = [[UILabel alloc] init];
        _videoLabel.font = UIFontMake(14);
        [_videoLabel setTextColor:UIColorMakeWithHex(@"#666666")];
        _videoLabel.numberOfLines = 0;
    }
    return _videoLabel;
}
- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = UIColorMakeWithHex(@"#E5E5E5");
    }
    return _lineView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
